package com.kkshop.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.test.AbstractDependencyInjectionSpringContextTests;

import com.kkshop.test.fixture.Fixture;

public abstract class AbstractSpringTestCase extends AbstractDependencyInjectionSpringContextTests {
	
	private List<Fixture> fixtures = new ArrayList<Fixture>();
	
	protected String[] getConfigLocations() {
        return new String[] {
                "classpath*:spring/ApplicationContext*Test.xml"
        };
    }

	protected void onSetUp() throws Exception {
		super.onSetUp();
		for(Fixture fixture : fixtures) {
			fixture.setUp();
		}
	}

	protected void onTearDown() throws Exception {
		super.onTearDown();
		for(Fixture fixture : fixtures) {
			fixture.tearDown();
		}
	}
	
	protected void addFixture(Fixture fixture) {
		fixtures.add(fixture);
	}
	
	protected void removeFixture(Fixture fixture) {
		fixtures.remove(fixture);
	}
}
